package org.wiztools.oembed;

/**
 * Defines the common methods used in all <code>org.wiztools.oembed.OEmbedExecutor</code> implementations.
 * @author subhash
 */
public abstract class OEmbedAbstractExecutor implements OEmbedExecutor {
    /**
     * 
     * @param contentType The content-type value extracted from the HTTP header.
     * @return The oEmbed parser implementation which corresponds to the content type.
     */
    protected OEmbedParser getParser(final String contentType) {
        if(contentType.startsWith("text/xml")) {
            return new OEmbedXmlParser();
        }
        else if(contentType.startsWith("application/json")) {
            return new OEmbedJsonParser();
        }
        else {
            throw new UnsupportedOperationException("Unsupported content-type in response: " + contentType);
        }
    }
}
